using namespace std;
#include "commun.h"

char* dtd_fileName;

int xml_parse(XMLArbre**);

extern int xml_debug;

extern FILE * xml_in;

int main(int argc, char **argv)
{
	int err;
	XMLArbre * arbreXML;
	XMLArbre * arbreXSL;
	FILE * fid;

	//xml_debug = 1; // pour enlever l'affichage de l'éxécution du parser, commenter cette ligne

	printf("nb de parametres: %d\n", argc);

/*
	for(int i = 1 ; i < argc ; i++)
	{
		printf("nb du %d parametre est '%s'\n", i, argv[i]);
		fid = fopen(argv[i], "r");
		xml_in = fid;
		err = xml_parse(&arbreXML);
		if (err != 0) 
		{
			printf("Parse xml ended with %d error(s)\n", err);
			return 1;
		}

	  	printf("Parse xml ended with success\n");
		fclose(fid);
		printf("**************************************************************************************************\n");
		arbreXML->afficher();
		printf("**************************************************************************************************\n");
		printf("**************************************************************************************************\n");
	}
*/
	//fid = fopen(argv[1], "r");
	fid = fopen("test_files/test1.xml", "r");
	xml_in = fid;
	err = xml_parse(&arbreXML);
	if (err != 0) 
	{
		printf("Parse xml ended with %d error(s)\n", err);
		return 1;
	}

  	printf("Parse xml ended with success\n");
	fclose(fid);
	printf("**************************************************************************************************\n");
	arbreXML->afficher();
	printf("**************************************************************************************************\n");
	printf("**************************************************************************************************\n");

	//fid = fopen(argv[2], "r");
	fid = fopen("test_files/transform.xsl", "r");
	xml_in = fid;
	err = xml_parse(&arbreXSL);
	if (err != 0) 
	{
		printf("Parse xml ended with %d error(s)\n", err);
		return 1;
	}

  	printf("Parse xml ended with success\n");
	fclose(fid);
	printf("**************************************************************************************************\n");
	arbreXSL->afficher();
	printf("**************************************************************************************************\n");
	printf("**************************************************************************************************\n");

	HTMLArbre * html = new HTMLArbre(*arbreXSL, *arbreXML);
	
	return 0;
}
